# 1.导模块
from pptx import Presentation

# 2.文稿创建
from pptx.enum.chart import XL_CHART_TYPE
from pptx.util import Inches

pre = Presentation()

# 3.添加 6号的  幻灯片
slider = pre.slides.add_slide(pre.slide_layouts[6])

# 4. 构建 折线图的 数据
from pptx.chart.data import ChartData

chart_data = ChartData()
chart_data.categories = ['2017', '2018', '2019']
chart_data.add_series('17', (32.2, 28.4, 34.7))
chart_data.add_series('18', (24.3, 30.6, 20.2))
chart_data.add_series('19', (20.4, 18.3, 26.2))

# 5.设置位置
x, y, cx, cy = Inches(2), Inches(2), Inches(6), Inches(4.5),

# 6.添加折线图
chart = slider.shapes.add_chart(
    XL_CHART_TYPE.LINE, x, y, cx, cy, chart_data
).chart

# 设置折线图的 样式
chart.has_legend = True
chart.legend.include_in_layout = False
chart.series[0].smooth = True

# 保存文稿
pre.save('09line.pptx')
print('折线图....')
